package com.liuceng.zen.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.liuceng.zen.Page;
import com.liuceng.zen.pojo.domain.MemberAccountFlow;
import com.liuceng.zen.pojo.form.MemberAccountFlowForm;
import com.liuceng.zen.service.MemberAccountFlowService;
import com.liuceng.zen.service.MemberService;

/**
 * 账户功能
 * 
 * @author Administrator
 *
 */

@Controller
@RequestMapping(value = "/account")
public class AccountController extends BaseController {

  @Autowired
  public MemberService memberService;

  @Autowired
  public MemberAccountFlowService memberAccountFlowService;

  // 账号管理
  @RequestMapping(value = "", method = RequestMethod.GET)
  public String account() {
    return "acconManage/acconManage";
  }


  // 账号流水
  @RequestMapping(value = "/flow", method = RequestMethod.GET)
  public String cashlist() {
    return "acconManage/flow";

  }


  @RequestMapping(value = "/flow", method = RequestMethod.POST)
  public @ResponseBody Object getForms(MemberAccountFlowForm flowForm, HttpServletRequest req) {
    // 初始化信息
    flowForm.setSortInfo(req);
    flowForm.setMemberId(getCurrentUserId());
    Page<MemberAccountFlow> memberAccountFlows = memberAccountFlowService.findPage(flowForm);
    List<MemberAccountFlow> list = memberAccountFlows.getContent();
    Map<String, Object> filterMap = new HashMap<String, Object>();
    filterMap.put("sEcho", 0);
    filterMap.put("iTotalRecords", memberAccountFlows.getContent().size());// 实际的行数
    filterMap.put("iTotalDisplayRecords", memberAccountFlows.getTotalCount());// 总行数
    filterMap.put("data", memberAccountFlows.getContent());// 要以JSON格式返回
    return filterMap;
  }

  @RequestMapping(value = "/flows", method = RequestMethod.GET)

  public String getErro(MemberAccountFlowForm flowForm, HttpServletRequest req) {
    return "pages/500";
  }


}
